<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function count(type) {
        var i = 0;

        function doPlus() {

            i++;
            console.log(type + ':' + i);
        }

        return doPlus;
    }

    var funA = count('A');
    var funB = count('B');

    funA();
    funA();
    funA();

    funB();
    funB();
    funB();


</script>
</body>
</html>